package com.swingson;

/**
 * @author sad
 */
public class Swingson {

    private static int eventsEnabled = 0;

    public static void enableUserInput() {
        if (eventsEnabled < 0) {
            eventsEnabled++;
        }
    }

    public static UserInputEnabler disableUserInput() {
        eventsEnabled--;
        return new UserInputEnabler();
    }

    public static boolean isEnabledUserInput() {
        return eventsEnabled >= 0;
    }

    public static class UserInputEnabler implements AutoCloseable {

        @Override
        public void close() {
            enableUserInput();
        }
    }
}
